package com.masterclient.app.modules.pickgoods.contract;

import com.eoner.baselib.container.CommonBaseResponse;
import com.eoner.baselib.presenter.ThrowableConsumer;
import com.masterclient.app.httpservice.RetrofitUtil2;
import com.masterclient.app.modules.pickgoods.beans.PickGoodsBean;

import io.reactivex.Observable;
import io.reactivex.disposables.Disposable;
import io.reactivex.functions.Consumer;

/**
 * Created by TMVPHelper on 2017/08/27
 */
public class PickGoodsListPresenter extends PickGoodsListContract.Presenter {

    @Override
    public void getPickGoodsListInfo() {
        Observable<CommonBaseResponse<PickGoodsBean>> observable = RetrofitUtil2.getInstance().getPickGoodsListInfo();
        Disposable disposable = toSubscribe(observable, (Consumer<CommonBaseResponse<PickGoodsBean>>) bean -> {
            if (bean.getCode() == 0) {
                mView.showPickGoodsListInfo(bean.getData());
            } else {
                mView.showFail(bean.getMsg());
            }
        }, new ThrowableConsumer());
        mRxManager.add(disposable);
    }
}